package com.android.fragmentdemo
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import com.android.fragmentdemo.adapters.SnapHelperAdapter
import com.hengfoxwolf.commonbase.base.BaseActivity
import com.android.fragmentdemo.databeans.DataFactoryIp
import com.android.fragmentdemo.databinding.ActivitySnapHelperBinding
import com.android.fragmentdemo.defineviews.SnapHelperItemDecoration
import com.android.fragmentdemo.snaphelper.CustomCenterSnapHelper

class SnapHelperActivity : BaseActivity<ActivitySnapHelperBinding>() {

    override fun verticalLayout() : Boolean {
        return false
    }

    override fun getLayoutId() = R.layout.activity_snap_helper

    override fun init(savedInstanceState: Bundle?) {

        val dataSet = DataFactoryIp.createCharStr(15)

        mBinding.snapHelperRv.apply {
            layoutManager =
                LinearLayoutManager(this@SnapHelperActivity, LinearLayoutManager.HORIZONTAL, false)

            adapter = SnapHelperAdapter().apply {
                itemDataSet = dataSet
            }

            addItemDecoration(
                SnapHelperItemDecoration(
                    this@SnapHelperActivity.resources.getDimension(
                        R.dimen.dp_15
                    ).toInt()
                )
            )
        }

        CustomCenterSnapHelper().attachToRecyclerView(mBinding.snapHelperRv)
        //CustomLeftSnapHelper().attachToRecyclerView(mBinding.snapHelperRv)
        //CustomRightSnapHelper().attachToRecyclerView(mBinding.snapHelperRv)
    }

}